/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.tewi.annotations.processors;

import pl.tewi.contexts.ApplicationServerContext;
import pl.tewi.annotations.ApplicationServer;
import pl.tewi.annotations.Ports;
import pl.tewi.exceptions.AnnotationProcessingException;
import pl.tewi.exceptions.GeneralFrameworkException;
import pl.tewi.types.InstancePorts;

/**
 *
 * @author Marcin Kwapisz
 */
public class PortAnnotationProcessor implements AnnotationProcessor {

    /**
     * 
     * @param klass
     * @param context
     * @return
     * @throws AnnotationProcessingException
     * @throws GeneralFrameworkException 
     */
    public ApplicationServerContext processAnnotations(final Class<?> klass, final ApplicationServerContext context) throws AnnotationProcessingException, GeneralFrameworkException {
        ApplicationServer applicationServer = klass.getAnnotation(ApplicationServer.class);
        Ports ports = applicationServer.instancePorts();
        context.setInstancePorts(new InstancePorts(ports.admin(), ports.http(), ports.https(), ports.iiop(), ports.iiops(), ports.jms(), ports.jmx()));
        return context;
    }
}
